<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
<link type="text/css" rel="stylesheet" href="css/layout.css" />
<title>Danh sách sản phẩm của shop</title>

</head>

<body>
<?php include("menu.php"); 
include("session.php");
include("../include/config.php");
?>
<?php
if(isset($_REQUEST["cmd"]) && $_REQUEST["cmd"] == "del"){
              $id_del = $_REQUEST["id"];
              $sqldel="DELETE FROM product WHERE id=$id_del";
			  mysql_query($sqldel);
			  header("Location:product.php");
			}		
?>	

<div id="head-noidung">
	<div id="head-main">
<p>Danh sách sản phẩm của E-Plus.  <span><a href="product_add.php">Thêm mới</a></span></p>
<table class="classtable">
<thead>
	<tr>
		<th>STT</th>
		<th>Tên SP</th>
		<th>Mã</th>
		<th>Giá</th>
		<th>Loại</th>
		<th>Hoạt động</th>
		<th>Thao tác</th>
	</tr>
</thead>		
<?php 
$sql1="SELECT * FROM product ORDER By id DESC";
$rs1=mysql_query($sql1);
if($rs1) {
 $i=1;
 while($rw1=mysql_fetch_array($rs1)) {
	
?>

<tbody>
<tr>

	<td><?php echo $i?></td>
	<td><?php echo $rw1["name"];?></td>
	<td><?php echo $rw1["code"];?></td>
	<td><?php echo number_format($rw1["price"],0,',','.');?></td>
			<td>
			<?php 
			$sql2="SELECT * FROM subcategory WHERE id='".$rw1["subcategory"]."'";
			$rs2=mysql_query($sql2);
			$row=mysql_fetch_array($rs2);
			?>
			
			<?php echo $row["name"];?>
			
			
			</td>	
	<td><?php if($row["status"]==1) { ?> <img src="images/yes.png" width="23" height="22"/><?php } else { ?> <img src="images/no.png" width="23" height="22"/> <?php } ?></td>		
			<td><a href="product_edit.php?id=<?php echo $rw1["id"];?>">Sửa</a> <a href="product.php?cmd=del&id=<?php echo $rw1["id"];?>" onclick="return confirm('Ban muon xoa ?');" href="?id=<?php echo $rw1["id"];?>">Xóa</a></td>								
</tr>
<?php 
$i+=1;
}

} ?>	
	
	
<?php 
	if(isset($_REQUEST["del"]))
	{
		$id=$_REQUEST["id"];
		echo $id;
	}

?>	

</tbody>

</table>
	
	</div>	
</div>

<?php include("images/cherry/footer.php"); ?>

</body>
</html>
